import 'package:share_fit/app/helper/storage_helper.dart';
import 'package:share_fit/app/tools/locale_tool.dart';

import 'net_const.dart';

class NetTool {

  static bool hasToken() {
    return getToken().isNotEmpty;
  }

  static String getToken() {
    String token = StorageHelper.read(NetConst.keyUserToken, defaultValue: "");
    return token;
  }
  static Map<String, dynamic> getHeaders({Map<String, dynamic>? extras}) {
    Map<String, dynamic> headers = {};
    headers[NetConst.keyAppId] = 'gofit';
    if (extras != null) {
      headers.addAll(extras);
    }
    return headers;
  }

  static Map<String, dynamic> getHeadersWithToken() {
    Map<String, dynamic> headers = {};
    headers[NetConst.keyToken] = getToken();
    return getHeaders(extras: headers);
  }

  static Map<String, dynamic> getHeadersWithLanguage() {
    Map<String, dynamic> headers = {};
    // headers[NetConst.keyLanguage] = LocaleTool.getCurrentLanStr();
    headers[NetConst.keyLanguage] = "en";
    return getHeaders(extras: headers);
  }
}